/* Orbas:
 *     A open source CORBA Specification implementation from Huihoo.
 *
 * Copyright 2002-2003 Huihoo.org, Inc. All Right Reserved.
 *
 * This software is licensed under LGPL license.
 * See terms of license at gnu.org.
 *
 * For more information, visit:
 *
 * http://www.huihoo.org/orbas
 */



package org.huihoo.orbas.orb.protocols.iiop;

/**
 * <p>Description: </p>
 * Transport for TCP procotol.
 * <p>Copyright (c) 2002,2003</p>
 * <p>Company: <a href="http://www.huihoo.org/">huihoo.org</a></p>
 * @author <a href="http://www.huihoo.org/~mep">mep(mep@huihoo.com)</a>
 * @see <a href="http://www.huihoo.org/orbas">http://www.huihoo.org/orbas</a>
 * @version 1.0
 */


import javax.microedition.io.ServerSocketConnection;
import javax.microedition.io.SocketConnection;
import javax.microedition.io.StreamConnection;
import org.huihoo.orbas.orb.protocols.*;

public class IiopTransport extends Transport {

    private IiopTargetAddress address;
    private final SocketConnection sock;
    private final StreamConnection serverConn;
    private java.io.InputStream istream;
    private java.io.OutputStream ostream;

    private IiopChannel channel;

    /**
     * Creates a transport object used for the client side of a connection.
     * @param ch the IIOP channel to use.
     * @param sock the client socket connection to communicate through.
     * @param a the address to connect to.
     */
    public IiopTransport(IiopChannel ch, SocketConnection sock, IiopTargetAddress a){
        this.channel = ch;
        this.sock = sock;
        this.serverConn = null;
        this.address = a;

        try {
            istream = sock.openDataInputStream();
            ostream = sock.openOutputStream();
        }
        catch (java.io.IOException e) {
            System.out.println("IOException in IiopTransport constructor");
        }

    }

    /**
     * Creates a transport object used for the server side of a connection.
     * @param conn the streaming connection returned from a ServerSocketConnection
     */
    public IiopTransport(StreamConnection conn){
        this.channel = null;
        this.sock = null;
        this.serverConn = conn;
        this.address = null;
        try {
            istream = serverConn.openDataInputStream();
            ostream = serverConn.openOutputStream();
        }
        catch (java.io.IOException e) {
            System.out.println("IOException in IiopTransport constructor");
        }


    }

    public int getProtocolTag() {
        return org.omg.IOP.TAG_INTERNET_IOP.value;
    }

    public TargetAddress getTargetAddress() {
        return address;
    }

    public java.io.InputStream getInputStream() {
        return istream;
    }

    public java.io.OutputStream getOutputStream() {
        return ostream;
    }

    public void teardown(boolean wait) {

    }

}